<!DOCTYPE html>
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="ie=edge" />
		<title>订单管理-鹿程智慧油站商户平台</title>
		<meta name="description" content="鹿程科技是提供加油站互联网化零管系统、营销及支付和大数据分析运营服务的行业领先科技公司。鹿程科技充分了解加油站行业的需求和新兴互联网的发展,依靠业内最先进的科技和标准化的运营,持续帮助油站业务发展创造价值。"/>
		<meta name="keywords" content="智慧油站,鹿程,鹿程智慧油站,鹿程智慧油站微信支付,加油站微信支付,加油站营销管理"/>
		<link rel="icon" href="https://static.zhihuiyouzhan.com.cn/static/styles/admin/img/title.ico" type="image/x-icon">
		<link rel="shortcut icon" href="https://static.zhihuiyouzhan.com.cn/static/styles/admin/img/title.ico" type="image/x-icon">
		<link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
		<link rel="stylesheet" href="../layui/css/layui.css" />
		<link rel="stylesheet" href="../css/style.css" />
	</head>
<body>
	<section class="section-right">
	<div class="deer-tit marke-tit">
		<h3>消费送券</h3>
		<h4>创建活动</h4>
	</div>
	<article class="ware-contents">
		<!--form-->
		<form class="layui-form">
			<!--ware-content-input-->
			<section class="ware-c-input marke-c-input">
				<dl>
				    <dt><i class="must">*</i>应用场景：</dt>
					<dd>
						<select name="idx_trigger" lay-filter="select">
                            <option value="0">注册</option>
                            <option value="1">消费</option>
                            <option value="2">充值</option>
						</select>
					</dd>
			  	</dl>
			  	<dl>
				    <dt><i class="must">*</i>活动名称：</dt>
				    <dd><input type="text" name="title" lay-verType="tips" lay-verify="required" placeholder="请输入活动名称" class="layui-input" maxlength="50" /></dd>
			  	</dl>
			  	<dl>
				    <dt><i class="must">*</i>赠送优惠券：</dt>
				    <dd>
				    <select name="coupon_id">
                        <option value="49">一键召回测试(5.00-10.00)</option>
                        <option value="44">冬季温情活动(3.00-6.00)</option>
                        <option value="114">砍价券(30.00)</option>
                        <option value="116">群发优惠券测试(8.00)</option>
                        <option value="119">春季出游助力加油券(5.80)</option>
                        <option value="66">测试砍价券(10.00)</option>
                        <option value="98">消费送券测试(5.00)</option>
                        <option value="102">便利店优惠券(10.00-20.00)</option>
                        <option value="103">消费送券(5.00)</option>
                    </select>
                    </dd>
			  	</dl>
			  	<dl>
				    <dt><i class="must">*</i>单次赠送优惠券量：</dt>
				    <dd><input type="number" name="coupon_num" min="0" lay-verify="required|num" placeholder="请输入单次赠送优惠券数量" class="layui-input"></dd>
			  	</dl>
			  	<dl>
				    <dt>赠送余额：</dt>
				    <dd><input type="number" name="money" min="0" placeholder="请输入赠送余额" class="layui-input"></dd>
			  	</dl>
		  		<dl>
				    <dt><i class="must">*</i>活动时间：</dt>
				    <dd><input type="text" name="activity_time" lay-verify="required" lay-verType="alert" id="datetime" placeholder="请选择活动时间" class="layui-input"  /></dd>
			  	</dl>
		  		<dl class="consume">
				    <dt><i class="must">*</i>注册时间：</dt>
				    <dd><input type="text" name="title" id="datetime2" lay-verify="required" lay-verType="alert" placeholder="请选择注册时间" class="layui-input" /></dd>
				    <code>注:此时间注册之后的用户可参与本活动</code>
			  	</dl>
			  	<dl>
				    <dt><i class="must">*</i>可参数次数：</dt>
				    <dd><input type="text" name="signin_num" lay-verify="required|numb"  placeholder="请输入可参加次数" class="layui-input" /></dd>
				    <code>注:单个会员可参与本活动的次数</code>
			  	</dl>
			  	<dl class="consume">
				    <dt><i class="must">*</i>等级会员：</dt>
				    <dd style="line-height: 36px;" id="number" lay-verify="numbe" lay-verType="tips"  >
				    	<input type="checkbox" title="全选"  name='number' />
				    	<input type="checkbox" title="普通会员" name='number1' />
				    	<input type="checkbox" title="中级会员" name='number1' />
				    	<input type="checkbox" title="至尊会员 " name='number1' />
				    	<input type="checkbox" title="初级会员" name='number1' />
				    	<input type="checkbox" title="高级会员" name='number1' />
				    	<input type="checkbox" title="银卡会员" name='number1' />
				    </dd>
			  	</dl>
			  	<dl class="consume">
				    <dt><i class="must">*</i>最低充值金额</dt>
				    <dd><input type="number" min="0" lay-verify="required|num" lay-verType="tips" name="order_money" placeholder="请输入最低充值金额" class="layui-input" maxlength="50" /></dd>
				    <code>注:参与本活动单笔订单必须达到最低充值金额</code>
			  	</dl>
			</section>
			<!--/ware-content-input-->
			<!--submit-->
			<div class="ware-submit">
				<span class="submit" lay-submit lay-filter="submit"  />提交</span>
			</div>
			
			<!--/submit-->
		</form>
		<!--/form-->
	</article>
	</section>
	<!--js-->
	<aside>
		<script type="text/javascript" src="../layui/layui.js" ></script>
		<script type="text/javascript">
			layui.use(['form','jquery','laydate','layer'],function(){
				var form=layui.form;
				var $=layui.jquery;
				var layer=layui.layer;
				var laydate=layui.laydate;
				
				
				laydate.render({
					elem:'#datetime',
					type:'datetime',
					range:'/',
				})
				laydate.render({
					elem:'#datetime2',
					type:'datetime',
				})
				
  
				 
				 
				 form.verify({
				  	num: [                 //判断是否为数字
					    /^((?:[0-9]\d*))(?:\.\d{1,2})?$/
					    ,'请输入一个合理的价格'   
					],
					numb:[
						/^[1-9]+[0-9]*$/
						,'请输入一个 正确的整数'
					],
					numbe:function(){
						var num=0;
						$('#number>input').each(function(index,item){
							if($(item).prop('checked')==true){
								num++
								console.log('1212')
							}
						})
						
						if(!num){
							return '您尚未选中任何会员等级'
						}
						
					}
				
		 		})
				 //初始化隐藏
				$('.consume').slideUp()
				//不再验证
				$('#datetime2').attr('lay-verify','')
				$('#number').attr('lay-verify','')
				$("[name='order_money']").attr('lay-verify','')



				form.on('select(select)',function(item){
					var index=item.value
					if(index==0){
						$('.consume').slideUp()
						//不再验证
						$('#datetime2').attr('lay-verify','')
						$('#number').attr('lay-verify','')
						$("[name='order_money']").attr('lay-verify','')
//						清空
						$('#datetime2').val('')
						$("[name='order_money']").val('')
						//清空选中的会员
						$('#number>input').each(function(index,item){
							item.checked=false
						})
					}else{
						$('.consume').slideDown()
						//验证
						$('#datetime2').attr('lay-verify','required')
						$('#number').attr('lay-verify','numbe')
						$("[name='order_money']").attr('lay-verify','required|num')
						form.render('checkbox')
					}
				})
				
				
				//表单提交
				form.on('submit(submit)', function(data){
				  console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}
				  return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
				});


			//全选
			 form.on('checkbox(numbers)', function(data){
                checkeds(data)
            });
			checkedAlls($('#numbers'))
			 //判断是否全选
            function checkeds(data){
                var checkDiv=$(data.elem).parent().children('.layui-form-checkbox')
                var checked=$(data.elem).parent().children(':checkbox')
                if($(data.othis).hasClass('layui-form-checked')){
                    checkDiv.addClass('layui-form-checked')
                    checked.each(function(index,value){
                        value.checked = data.elem.checked;
                    })
                }else{
                    checkDiv.removeClass('layui-form-checked')
                    checked.each(function(index,value){
                        value.checked = data.elem.checked;
                    })
                }
            }
            
			//全选判断
            function checkedAlls(all){
            	var nums=0
				all.on('click','.layui-form-checkbox',function () {
					var num=0
					all.find('.layui-form-checkbox:gt(0)').each(function(index,value){
						if($(value).hasClass('layui-form-checked')==false){
							num++
						}
					})
					if(num){
						all.find('.layui-form-checkbox').eq(0).removeClass('layui-form-checked')
					}else{
						all.find('.layui-form-checkbox').eq(0).addClass('layui-form-checked')
					}
				})
				
					all.find('.layui-form-checkbox:gt(0)').each(function(index,value){
						if($(value).hasClass('layui-form-checked')==false){
							nums++
						}
					})
					if(nums){
						all.find('.layui-form-checkbox').eq(0).removeClass('layui-form-checked')
					}else{
						all.find('.layui-form-checkbox').eq(0).addClass('layui-form-checked')
					}
				
			}
			
		})
		</script>
	</aside>
	<!--/js-->
	
	
	
	
	
	
	
	
</body>
</html>